package com.cn.reflect;

import java.lang.reflect.Field;

/**
 * @program: demo
 * @description:
 * @author: yihanyuan
 * @create: 2018-12-05 15:39
 **/
public class ReflectTest {
    public static void main(String[] args) {
        Class c = User.class;
        System.out.println(c);
        System.out.println(c.getName());
        //获取public参数
//        for (Field s : c.getFields()) {
//            System.out.println("public参数类型---" + s.getType());
//            System.out.println("public参数名称---" + s.getName());
//        }
//        for (Method m : c.getMethods()) {
//            System.out.println(m.getName());
//        }
        //获取值
        try {
            Field f = c.getField("NORMAL");
            try {
                Object name = f.get("NORMAL");
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
    }
}
